// 药水类
class Potion {
    constructor(name, description, effect, rarity = 'common') {
        this.name = name;
        this.description = description;
        this.effect = effect;
        this.rarity = rarity;
        this.used = false;
    }

    // 使用药水
    use(player) {
        if (this.used) return false;
        
        switch (this.name) {
            case '777感冒灵':
                player.heal(25);
                break;
            case '糖水':
                player.energy += 2;
                break;
            case '可乐':
                player.addStrength(2, 'battle');
                break;
            case '香蕉':
                player.addDexterity(2, 'battle');
                break;
            case '酒':
                player.addIntelligence(2, 'battle');
                break;
        }
        
        this.used = true;
        return true;
    }
}

// 药水数据库
class PotionDatabase {
    constructor() {
        this.potions = this.initializePotions();
    }

    // 初始化所有药水
    initializePotions() {
        return [
            new Potion('777感冒灵', '恢复25点生命值', { type: 'heal', value: 25 }, 'common'),
            new Potion('糖水', '获得2点能量', { type: 'energy', value: 2 }, 'common'),
            new Potion('可乐', '获得2点力量', { type: 'strength', value: 2 }, 'common'),
            new Potion('香蕉', '获得2点敏捷', { type: 'dexterity', value: 2 }, 'common'),
            new Potion('酒', '获得2点智力', { type: 'intelligence', value: 2 }, 'common')
        ];
    }

    // 获取随机药水
    getRandomPotion() {
        return this.potions[Math.floor(Math.random() * this.potions.length)];
    }

    // 获取随机药水池
    getRandomPotionPool(count = 3) {
        const shuffled = [...this.potions].sort(() => 0.5 - Math.random());
        return shuffled.slice(0, count);
    }

    // 获取所有药水
    getAllPotions() {
        return this.potions;
    }

    // 根据名称获取药水
    getPotionByName(name) {
        return this.potions.find(potion => potion.name === name);
    }
}

// 药水效果处理器
class PotionEffectProcessor {
    static processPotion(potion, player) {
        switch (potion.name) {
            case '777感冒灵':
                player.heal(25);
                break;
            case '糖水':
                player.energy += 2;
                break;
            case '可乐':
                player.addStrength(2, 'battle');
                break;
            case '香蕉':
                player.addDexterity(2, 'battle');
                break;
            case '酒':
                player.addIntelligence(2, 'battle');
                break;
        }
    }
}

// 全局药水数据库实例
const potionDatabase = new PotionDatabase();
